package ioStream.file.processStream.byteStream;

import java.io.FileInputStream;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA
 * Description:缓冲字节输入流学习
 * User:22954
 * Date:2024-03-18
 * Time:15:18
 */
@SuppressWarnings("all")
public class BufferedInputStream_ {
    /*
    BufferedInputStream extends FilterInputStream extends InputStream
                                protected volatile InputStream in
    BufferedInputStream(InputStream in)  包装节点输入流
    ===================================================================
    close()->input.close() 关闭处理流,底层也会关闭节点流
     */
    public static void main(String[] args) {
        String filePath = "f:/Test/hello_world.txt";
        java.io.BufferedInputStream bi = null;
        int data = 0;
        try {
            bi = new java.io.BufferedInputStream(new FileInputStream(filePath));
            while ((data = bi.read()) != -1){
                System.out.print((char) data);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                bi.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
